<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <li>01</li>
    <li>02</li>
    <li>03</li>
    <li>04</li>
    <li>05</li>
    <li>06</li>
    <li>07</li>
    <li>08</li>
    <li>09</li>
    <li>10</li>
</body>
<script>
    // 自定义构造函数  
    function Cat(name, color) {
        this.name = name;
        this.color = color;
    }

    Cat.prototype.species = "Cat";
    Cat.prototype.hall = function () {
        console.log("喵喵", "老吴");
    }
    Cat.prototype.skill = function () {
        console.log("捉老鼠", "卖萌");
    }
    Cat.prototype.say = function () {
        console.log(this.name, this.color);
    }

    // Cat.prototype.toString = function () {
    //     return "hello," + this.name;
    // }

    Object.prototype.a = 1;
    Object.prototype.b = 2;
</script>
<script>
    // call apply之伪数组转真数组


    var liList = document.querySelectorAll("li");
    console.log(liList);


    /* Array.prototype._slice = function (startIndex = 0, endIndex = this.length) {
        // this -> 调用此方法的实例化对象
        var arr = [];
        for (var i = startIndex; i < endIndex; i++) {
            arr.push(this[i]);
        }
        return arr;
    }*/

    // [1,2,3,4,5].slice()

    //   通过原型对象取slice方法
    var list = Array.prototype.slice.call(liList);
    var list = Array.prototype.slice.apply(liList);

    // 通过数组.__proto__找Array.prototype.slice
    var list = [].slice.apply(liList);
    console.log(list, Array.isArray(list));



    // 取数组最大值  

    var list = [1, 4, 7, 2, 5, 8, 3, 6, 9];

    // var max = Math.max(...list);
    // console.log(max);

    /* 
    Math.max(1, 4, 7, 2, 5, 8, 3, 6, 9)
    Math._max = function () {
        var max = 0;
        for (var i = 0; i < arguments.length; i++) {
            var item = arguments[i];
            if (item > max) {
                max = item;
            }
        }
        return max;
    } */

    // 把接收多参数的函数改为接收数组
    var list = [1, 4, 7, 2, 5, 8, 3, 6, 9];
    var max = Math.max.apply(null, list);
    // console.log(max);


    // 判断数据是否是纯对象数据?  new Object()    自定义构造函数 {a:1,b:2}

    // toString()  将其他类型转化为字符串类型
    var num = 100;
    var str = "hello"
    var bool = true;
    var arr = [1, 2, 3];
    var obj = { a: 1, b: 2 };
    var Tom = new Cat("Tom", "black");

    // console.log(num.toString());  // 数字优先访问Number.prototype.toString  并没有访问 Object.prototype.toString
    // console.log(str.toString());  // 字符串优先访问String.prototype.toString  并没有访问 Object.prototype.toString
    // console.log(bool.toString()); // 布尔值优先访问Boolean.prototype.toString  并没有访问 Object.prototype.toString
    // console.log(arr.toString());  // 数组优先访问Array.prototype.toString  并没有访问 Object.prototype.toString
    // console.log(obj.toString());  //  访问 Object.prototype.toString  "[obejct Object]"
    // console.log(Tom.toString());  // 访问 Object.prototype.toString   "[obejct Object]"


    // 强制访问 Object.prototype.toString
    console.log(Object.prototype.toString.call(num));
    console.log(Object.prototype.toString.call(str));
    console.log(Object.prototype.toString.call(bool));
    console.log(Object.prototype.toString.call(arr));
    console.log(Object.prototype.toString.call(obj));
    console.log(Object.prototype.toString.call(Tom));


    console.log(Object.prototype.toString.call(arr) == "[obejct Array]");
    console.log(Object.prototype.toString.call(Tom) == "[obejct Object]");

    function isPlainObject(arg) {
        return Object.prototype.toString.call(arr) == "[obejct Object]";
    }







</script>

</html>